/*
 * @Author: your name
 * @Date: 2021-12-17 15:30:52
 * @LastEditTime: 2022-05-11 17:17:19
 * @LastEditors: 陈宇 975155172@qq.com
 * @Description: 定义具体的访问方法名
 * @FilePath: \blog-api\src\user\user..tscontroller
 */
import { Controller, Post, Body } from '@nestjs/common';
import { CategoriesService } from './categories.service';

import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { CreatePostDto, CategoriesDto, AddCategoriesPostDto, RemoveCategoriesPostDto, QueryCategoriesDto } from './dto/create-post.dot';

@ApiTags("分类")
@Controller('categories')
export class categories {
  constructor(private readonly categories: CategoriesService) {}
  
  // 获取列表
  @ApiOperation({ summary: '获取列表' })
  @Post('categoriesList')
  categoriesList(@Body() body: CreatePostDto): Promise<CategoriesDto> {
    return this.categories.list(body);
  }

  // 查询指定分类
  @ApiOperation({ summary: '查询指定分类' })
  @Post('queryCategories')
  queryCategories(@Body() body: QueryCategoriesDto): Promise<CategoriesDto> {
    return this.categories.queryCategories(body);
  }

  // 添加 / 修改 分类
  @ApiOperation({ summary: '添加 / 修改 分类' })
  @Post('addEditorCategories')
  addEditorTags(@Body() body: AddCategoriesPostDto): Promise<any> {
    return this.categories.addEditorCategories(body);
  }

  // 删除 分类
  @ApiOperation({ summary: '删除 分类' })
  @Post('removeCategories')
  removeTag(@Body() body: RemoveCategoriesPostDto): Promise<any> {
    return this.categories.removeCategories(body);
  }

  // 分类下文章数量减少
  @ApiOperation({ summary: '分类下文章数量添加' })
  @Post('addAbstractNum')
  addAbstractNum(@Body() body: QueryCategoriesDto): Promise<CategoriesDto> {
    return this.categories.addAbstractNum(body);
  }

  // 分类下文章数量减少
  @ApiOperation({ summary: '分类下文章数量添加' })
  @Post('reduceAbstractNum')
  reduceAbstractNum(@Body() body: QueryCategoriesDto): Promise<CategoriesDto> {
    return this.categories.reduceAbstractNum(body);
  }
}
